﻿#ifndef LOGIN_H
#define LOGIN_H

#include "stdafx.h"
#include "ui_Login.h"

class Login : public QDialog
{
	Q_OBJECT

public:
	Login(QWidget *parent = nullptr);
	~Login();
	void paintEvent(QPaintEvent* event);
#ifdef Q_OS_WIN32
	bool nativeEvent(const QByteArray& eventType, void* message, long* result);
#endif

private:
	Ui::Login ui;
    QListWidget* m_listWidget;
    QMenu* m_statusMenu;
    QTcpSocket* m_socket;
    QString m_strHostAddress;
    unsigned short m_uPort;
    QTimer m_socketTimer;

private slots:
    void on_minisizeSysButton_clicked();
    void on_closeSysButton_clicked();
	void removeAccount(int index);
	void listWidgetCurrentItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
	void accountComboBoxItemChanged(int index);

	void on_signinButton_clicked();
    void on_cancelSigninButton_clicked();
    void socketConnected();
    void socketDisconnected();
    void socketError(QAbstractSocket::SocketError socketErr);
    void socketReadyRead();
    void socketTimeout();

private:
    void loadUsersData();
    void saveUserData();
    // 设置用户头像和特效
    void setUserPortrait(QPixmap pixmap = QPixmap());

public:
    QTcpSocket* socket();
};

#endif // LOGIN_H
